<?php

class CSellerScore extends Zend_Db_Table{
	
	protected $_name;
	
	protected $_primary;

	public function __construct($type){
		
		$this->_name=R_PRE."seller_scores_".$type;
		
		$this->_primary="orderid";
		
		parent::__construct();
		
	}

	public function createSellerScore($data){
		
		$this->insert($data);
		
	}
	
	public function editSellerScore($orderid,$data){
		
		$db=$this->getAdapter();
		
		$where = $db->quoteInto('orderid = ?', $orderid);
		
		$rows_affected=$db->update($this->_name,$data,$where);
		
		if($rows_affected!=1){
			
			return false;
			
		}else{
			
			return true;
			
		}
		
		
	}
	
	public function getDetail($orderid){
		
		$db=$this->getAdapter();
		
		$select = $db->select();

		$select->from($this->_name);
		
		$select->where('orderid = ? ',$orderid);
		
		return $db->fetchAll($select);
		
	}
	
	public function delSellerScores($orderidArray){
		
		$db=$this->getAdapter();
		
		$orderidString=join(',',$orderidArray);
		
		$result=$db->query("DELETE FROM $this->_name WHERE orderid IN ($orderidString)");
		
		return $result;
		
	}
	
	public function getAllSellerScores($orderid){
		
		$db=$this->getAdapter();
		
		$select = $db->select();
		
		$select->from($this->_name,'*');
		
		$select->where(" orderid = ? ",$orderid);
		
		return $db->fetchAll($select);
		
	}
	

	
}